package com.cswangdao.service.impl;

import com.cswangdao.domain.dto.FeedbackPageDTO;
import com.cswangdao.domain.model.MarketFeedback;
import com.cswangdao.mapper.MarketFeedbackMapper;
import com.cswangdao.result.PageResult;
import com.cswangdao.service.FeedbackService;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class FeedbackServiceImpl implements FeedbackService {
    @Autowired
    private MarketFeedbackMapper feedbackMapper;

    @Override
    public PageResult<MarketFeedback> pageQueryInfo(FeedbackPageDTO pageDTO) {
        try/* (SqlSession sqlSession = MybatisUtil.getSqlSession(true))*/{
          //  MarketFeedbackMapper feedbackMapper = sqlSession.getMapper(MarketFeedbackMapper.class);
            PageHelper.startPage(pageDTO.getPage(),pageDTO.getLimit());
            Page<MarketFeedback> feedbackPage = feedbackMapper.pageQueryInfo(pageDTO);
            PageResult<MarketFeedback> result = PageResult.result(feedbackPage);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
